package com.imooc.user.repository;

import com.imooc.user.mapping.GroupMapping;
import com.imooc.user.provider.model.UserCenterGroupVo;
import com.imooc.user.provider.model.UserCenterUserVo;
import com.imooc.user.provider.service.UserCenterGroupService;
import com.imooc.user.repository.entity.TUserCenterGroup;
import com.imooc.user.repository.entity.TUserCenterUser;
import com.imooc.user.repository.service.ITUserCenterGroupService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
@DubboService
public class GroupRepository implements UserCenterGroupService {

    private final ITUserCenterGroupService groupService;

    private final GroupMapping groupMapping;

    public GroupRepository(ITUserCenterGroupService groupService, GroupMapping groupMapping) {
        this.groupService = groupService;
        this.groupMapping = groupMapping;
    }


    @Override
    public UserCenterGroupVo getGroupByGroupId(String groupId) {
        TUserCenterGroup group = groupService.getGroupByGroupId(groupId);
        return groupMapping.convert(group);
    }

    @Override
    public List<UserCenterGroupVo> getGroupByGroupIds(List<String> groupIds) {
        List<TUserCenterGroup> groupByGroupIds = groupService.getGroupByGroupIds(groupIds);
        return groupMapping.convert(groupByGroupIds);
    }

    @Override
    public List<UserCenterGroupVo> getGroupsBySchoolId(Long schoolId, List<Integer> groupTypes) {
        List<TUserCenterGroup> groups = groupService.getGroupsBySchoolId(schoolId, groupTypes);
        return groupMapping.convert(groups);
    }

    @Override
    public List<UserCenterGroupVo> getGroupBySchoolId(Long schoolId, List<Integer> groupTypes) {
        List<TUserCenterGroup> groups = groupService.getGroupBySchoolId(schoolId, groupTypes);
        return groupMapping.convert(groups);
    }
}
